import request from "@/utils/index.js";

// 获取客户列表
export const getCustomerPageService = (currentPage, pageSize, cusName, city) => {
    return request.get("/api/customer/page", {params: {currentPage, pageSize, cusName, city}});
};

// 获取客户表数量
export const getCustomerCountService = () => {
    return request.get("/api/customer/count");
};

// 添加客户
export const addCustomerService = (data) => {
    return request.post("/api/customer/save", data);
};

// 删除客户
// 删除客户的服务方法
export const deleteCustomerService = (ids) => {
    // 将多个 ID 用逗号连接起来
    //如果 ids 是一个数组，则将数组中的元素用逗号连接起来
    if (Array.isArray(ids)) {
        ids = ids.join(",");
    }

    // 如果 ids 是一个数字，则将其转换为字符串
    if (typeof ids === "number") {
        ids = ids.toString();
    }
    // const idsParam = ids.join(",");
    return request.delete(`/api/customer/delete?ids=${ids}`);
};

// 修改客户
export const updateCustomerService = (data) => {
    console.log(data);
    return request.put("/api/customer/update", data);
};

// 获取全部客户
export const getCustomerListService = () => {
    return request.get("/api/customer/list");
};


